// pages/HomePage/index.js
Page({
    data: {
        topTitle: null,
        smallTitle: null,
        kill: null,
        commodity: null,
        random: [],
        sid: 0,
        brand: []
    },
    onLoad: function (options) {
        wx.request({
            // 标题
            url: 'http://460d80b632.zicp.vip/WeChat/homepage.php',
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: (res) => {
                let topTitle = res.data;
                this.setData({
                    topTitle: topTitle
                });
            }
        });

        wx.request({
            // 导航图下面
            url: 'http://460d80b632.zicp.vip/WeChat/small-rotation.php',
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: (res) => {
                let smallTitle = res.data;
                this.setData({
                    smallTitle
                });
            }
        });

        wx.request({
            // 京东秒杀
            url: 'http://460d80b632.zicp.vip/WeChat/kill.php',
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: (res) => {
                let kill = res.data;
                this.setData({
                    kill
                });
            }
        });

        wx.request({
            url: 'http://460d80b632.zicp.vip/WeChat/commodity.php',
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            data: {
                "ssid": 0
            },
            success: (res) => {
                let commodity = res.data;
                this.setData({
                    commodity
                });
            }
        });

        wx.request({
            url: 'http://460d80b632.zicp.vip/WeChat/getarandompic.php',
            success: (res) => {
                let random = res.data;
                this.setData({
                    random
                });
            }
        });

        wx.request({
            // 下面的商品
            url: 'http://460d80b632.zicp.vip/WeChat/commodity.php',
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            data: {
                "ssid": this.data.sid
            },
            success: (res) => {
                let commodity = res.data;
                this.setData({
                    commodity
                });
            }
        });
    },
    navBindtap: function (e) {
        "use strict";
        let sid = e.currentTarget.dataset.sid;
        this.setData({
            sid
        });

        wx.request({
            // 下面的商品
            url: 'http://460d80b632.zicp.vip/WeChat/commodity.php',
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            data: {
                "ssid": sid
            },
            success: (res) => {
                let commodity = res.data;
                this.setData({
                    commodity
                });
            }
        });

        wx.request({
            // 秒杀
            url: 'http://460d80b632.zicp.vip/WeChat/kill.php',
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success: (res) => {
                let kill = res.data;
                this.setData({
                    kill
                });
            }
        });

        wx.request({
            url: 'http://460d80b632.zicp.vip/WeChat/getBrand.php',
            method: "POST",
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            data: {
                'sid': sid
            },
            success: (res) => {
                let brand = res.data;
                this.setData({
                    brand
                });
            }
        })

    }
})